#!/bin/bash
if test -z "$arch"; then
	arch="i486"
	export arch
fi
DATE=`date +%Y%m%d`
PKG="oddiscovery"
USR="--owner 1000 --group 1000 --same-permissions"
EXCLUDE=' --exclude "*~" --exclude .svn '

echo "Network synchronizer" > pkg/$PKG.desc
echo "Demonstration scripts for oddiscovery" > pkg/${PKG}_demo.desc
cp pkg/*.desc ./var/pkg


make || exit 1
rm -fr pkg/*.gz
chmod +x usr/local/opendomo/*/*.sh 2>/dev/null
chmod +x usr/local/opendomo/*/*/*.sh 2>/dev/null
chmod o-rwx usr/local/opendomo/services/config/network/*.sh
chmod go-rx etc/init.d/oddiscovery

#DIRS="etc/opendomo etc/crond.d usr/bin usr/local/opendomo/discovery usr/local/opendomo/services/syscript var "
DIRS="etc/opendomo usr/bin usr/local/opendomo/discovery usr/local/opendomo/services/syscript var "

tar cf  pkg/$PKG-$DATE.od.$arch.tar $DIRS $USR $EXCLUDE
tar rf pkg/$PKG-$DATE.od.$arch.tar etc/init.d/oddiscovery --owner 0 --group 0 --same-permissions $EXCLUDE

gzip pkg/$PKG-$DATE.od.$arch.tar

#tar zcf  pkg/${PKG}_demo-$DATE.od.$ARCH.tar.gz usr/local/opendomo/services/tools $USR $EXCLUDE



